/**
*    Copyright (C) 2008  Chase Kernan 
*    chase.kernan@gmail.com
*
*    This program is free software: you can redistribute it and/or modify
*    it under the terms of the GNU General Public License as published by
*    the Free Software Foundation, either version 3 of the License, or
*    (at your option) any later version.
*
*    This program is distributed in the hope that it will be useful,
*    but WITHOUT ANY WARRANTY; without even the implied warranty of
*    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*    GNU General Public License for more details.
*
*    You should have received a copy of the GNU General Public License
*    along with this program.  If not, see <http://www.gnu.org/licenses/>.
* 
**/

package com.chasekernan.hxnova.server;

import com.chasekernan.hxnova.core.races.Race;
import com.chasekernan.hxnova.core.dataholders.Global;
import com.chasekernan.hxnova.core.dataholders.MessageHandler;
import com.chasekernan.hxnova.core.components.ComponentSet;


import com.chasekernan.hxnova.core.components.Armor;
import com.chasekernan.hxnova.core.components.Bomb;

import com.chasekernan.hxnova.core.fleets.Fleet;
import com.chasekernan.hxnova.core.minerals.MineralSet;
import com.chasekernan.hxnova.core.races.HabSetting;
import com.chasekernan.hxnova.core.races.Race;
import com.chasekernan.hxnova.core.races.ResearchCosts;
import com.chasekernan.hxnova.core.stars.Concentrations;
import com.chasekernan.hxnova.server.Server;

import com.chasekernan.hxnova.server.Game;
import haxe.Serializer;
import haxe.Unserializer;
import com.chasekernan.hxnova.server.IO;
import com.chasekernan.hxnova.utils.XmlSerializer;
import com.chasekernan.hxnova.core.stars.Concentrations;
import com.chasekernan.hxnova.core.stars.Environment;
import com.chasekernan.hxnova.core.races.TechLevel;
import com.chasekernan.hxnova.core.fleets.Salvage;
import com.chasekernan.hxnova.server.HostFile;
import com.chasekernan.hxnova.utils.Timing;

#if unit
import haxe.unit.TestRunner;
#end

class Main {
    public static function main() {
        #if unit
        runTests();
        #end
        
        //var races = new Array<Race>();
        //for (i in 0...12) races.push(new Race());
        
        //trace(Game.writeGameDataToXml("test", { races : races, map : { numStars : 500, type : MapType.Rectangle(500, 500) } }).toString());
        
        ServerEntry.run();
        /**
		Timing.init();
        
        ComponentSet.initialSetup();
        MessageHandler.init();
        Timing.record("initiation");
        
        var races = new Array<Race>();
        for (i in 0...12) races.push(new Race());
        
        Server.initGame(Game.createNewGame("game", {races : races, 
               map : { numStars : 500, type : MapType.Rectangle(500, 500) }} ));
                
        for (i in 0...1) Server.runTurn("game");
        trace(Global.year);
        
        Timing.print();
        **/
    }
    
    #if unit
    private static function runTests() {
        var runner = new TestRunner();
        
        runner.add(new MineralSetTest());
        runner.add(new ConcentrationsTest());
        runner.add(new EnvironmentTest());
        runner.add(new TechLevelTest());
        runner.add(new ResearchCostsTest());
        runner.add(new HabSettingTest());
        runner.add(new SalvageTest());
        runner.run();
    }
    #end
}


